package cn.aj.basic.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResultUtil {
	private Boolean success;
	private String msg;

	private Object resultObj;

	public AjaxResultUtil setSuccess(Boolean success) {
		this.success = success;
		return this;
	}

	public AjaxResultUtil setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public AjaxResultUtil success(){
		return AjaxResultUtil.getAjaxResult().setSuccess(true).setMsg("操作成功");
	}

	public AjaxResultUtil fail(){
		return AjaxResultUtil.getAjaxResult().setSuccess(false).setMsg("操作失败");
	}

	public AjaxResultUtil fail(String msg){
		return AjaxResultUtil.getAjaxResult().setSuccess(false).setMsg(msg);
	}
	/**
	* @Description: TODO
	* @Author: aj
	* @Version: 1.0
	* @Date:  2022/11/10 0010 13:34
	 * 提供一个静态方法
	 * 主要是高端
	*/
	public static AjaxResultUtil getAjaxResult() {
		return new AjaxResultUtil();
	}

	/**
	* @Title: setResultObject
	* @Description: TODO
	* @Author: Mr.GT
	* @Version: 1.0
	* @Date:  2022/11/19 0019 1:16
	* @Parameters: []
	* @Return cn.aj.basic.utils.AjaxResult
	 * 	// 链式编程
	*/
	public AjaxResultUtil setResultObj(Object resultObj) {
		this.resultObj=resultObj;
		return this;
	}
}
